(defpackage :feedback-examples
  (:use :cl)
  (:export :define-feedback-examples))

(in-package :feedback-examples)


(defun define-alert-example ()
  (spinneret:with-html
    (:div (:h3 "Alert")
          (:div (:h4 "Alert")
                (dui:alert "alert"
                           (icons:info)
                           "12 unread messages. Tap to see.")))
    ))

(defun define-loading-example ()
  (spinneret:with-html
    (:div (:h3 "Loading")
          (:div (:h4 "Loading spinner")
                (dui:loading "loading loading-spinner loading-xs")
                (dui:loading "loading loading-spinner loading-sm")
                (dui:loading "loading loading-spinner loading-md")
                (dui:loading "loading loading-spinner loading-lg")))
    ))

(defun define-progress-example ()
  (spinneret:with-html
    (:div (:h3 "Progress")
          (:div (:h4 "Progress")
                (:div (dui:progress "progress w-56" 0))
                (:div (dui:progress "progress w-56" 10))
                (:div (dui:progress "progress w-56" 40))
                (:div (dui:progress "progress w-56" 70))
                (:div (dui:progress "progress w-56" 100)))
          (:div (:h4 "Primary color")
                (:div (dui:progress "progress progress-primary w-56" 0))
                (:div (dui:progress "progress progress-primary w-56" 10))
                (:div (dui:progress "progress progress-primary w-56" 40))
                (:div (dui:progress "progress progress-primary w-56" 70))
                (:div (dui:progress "progress progress-primary w-56" 100)))
          (:div (:h4 "Primary color")
                (:div (dui:progress "progress progress-primary w-56" 0))
                (:div (dui:progress "progress progress-primary w-56" 10))
                (:div (dui:progress "progress progress-primary w-56" 40))
                (:div (dui:progress "progress progress-primary w-56" 70))
                (:div (dui:progress "progress progress-primary w-56" 100)))
          )))

(defun define-radial-progress-example ()
  (spinneret:with-html
    (:div (:h3 "Radial Progress")
          (:div (:h4 "Progress")
                (dui:radial-progress "radial-progress" 70))
          (:div (:h4 "Different values")
                (dui:radial-progress "radial-progress" 0)
                (dui:radial-progress "radial-progress" 20)
                (dui:radial-progress "radial-progress" 60)
                (dui:radial-progress "radial-progress" 80)
                (dui:radial-progress "radial-progress" 100))
          (:div (:h4 "Custom color")
                (dui:radial-progress "radial-progress text-primary" 70))
          (:div (:h4 "Custom size and custom thickness")
                (dui:radial-progress "radial-progress" 70 "--size:12rem; --thickness: 2px;")
                (dui:radial-progress "radial-progress" 70 "--size:12rem; --thickness: 2rem;"))
          )))

(defun define-tooltip-example ()
  (spinneret:with-html
    (:div (:h3 "Tooltip")
          (:div (:h4 "Tooltip")
                (dui:tooltip "tooltip" "hello" (dui:button "btn" "Hover Me")))
          (:div (:h4 "Force open")
                (dui:tooltip "tooltip tooltip-open" "hello" (dui:button "btn" "Hover Me")))
          (:div (:h4 "Bottom")
                (dui:tooltip "tooltip tooltip-open tooltip-bottom" "hello" (dui:button "btn" "Hover Me")))
          (:div (:h4 "Primary color")
                (dui:tooltip "tooltip tooltip-open tooltip-primary" "hello" (dui:button "btn" "Hover Me"))))
    ))


(defun define-feedback-examples ()
  (spinneret:with-html
    (:div
     (define-alert-example)
     ;; ...
     )))

(defun compile-alert-example ()
  (spinneret:with-html-string
    (define-alert-example)))

(defun compile-loading-example ()
  (spinneret:with-html-string
    (define-loading-example)))

(defun compile-progress-example ()
  (spinneret:with-html-string
    (define-progress-example)))

(defun compile-radial-progress-example ()
  (spinneret:with-html-string
    (define-radial-progress-example)))

(defun compile-tooltip-example ()
  (spinneret:with-html-string
    (define-tooltip-example)))


(easy-routes:defroute feedback-alert ("/feedback/alert" :method :get) ()
  (compile-alert-example))

(easy-routes:defroute feedback-loading ("/feedback/loading" :method :get) ()
  (compile-loading-example))

(easy-routes:defroute feedback-progress ("/feedback/progress" :method :get) ()
  (compile-progress-example))

(easy-routes:defroute feedback-radial-progress ("/feedback/radial-progress" :method :get) ()
  (compile-radial-progress-example))

(easy-routes:defroute feedback-tooltip ("/feedback/tooltip" :method :get) ()
  (compile-tooltip-example))
